package org.openqa.selenium.profiler.testserver;

import org.webbitserver.HttpControl;
import org.webbitserver.HttpHandler;
import org.webbitserver.HttpRequest;
import org.webbitserver.HttpResponse;

public class DelayedHttpHandler implements HttpHandler {

  private final int timeoutMillis;
  private final HttpHandler delegate;

  public DelayedHttpHandler(int timeoutMillis, HttpHandler delegate) {
    this.timeoutMillis = timeoutMillis;
    this.delegate = delegate;
  }

  @Override
  public void handleHttpRequest(HttpRequest request, HttpResponse response, HttpControl control)
      throws Exception {
    Thread.sleep(timeoutMillis);
    delegate.handleHttpRequest(request, response, control);
  }

}
